1 using UnityEngine;
2 using
UnityEngine.UI;
3 using
System.Collections;
4 using
System;
5 using
System.Collections.Generic;
6 //
using System.Net;
7
8 public
class DataDictionary : MonoBehaviour
9 {
10
11     
public static DataDictionary dd;
12
13     
// declare data to save across scenes here
14     
private bool isPlaying = true;
15     
private int levelNumber = 1;
16     
private int totalScore = 0;
17     
private int level1Score = 0;
18     
private bool hasShownInstructions = false;
19     
private int timeBonus = 0;
20     
private List<string> hitList = new List<string>();
21
22     
// Use this for initialization
23     
void Awake()
24     {
25         
if (dd == null)
26         {
27             DontDestroyOnLoad(gameObject);
28             dd =
this;
29             Debug.Log(
"DataDictionary::Awake: Application.persistentDataPath = [" + Application.persistentDataPath + "]");
30             init();
31         }
32         
else if (dd != this)
33         {
34             Destroy(gameObject);
// singleton pattern - do not allow more than one instance
35         }
36     }
37
38     
private void init()
39     {
40         Debug.Log(
"DataDictionary::init(): Initializing.");
41
42     }
43
44     
public static DataDictionary getDD()
45     {
46         
if (dd == null)
47         {
48             Debug.Log(
"DataDictionary::getDD(): DataDictionary set to null! Fatal error.");
49             
// TODO what do we do if DD does not exist?
50         }
51         
return dd;
52     }
53
54     
// add setters and getters here
55     
public int gettotalScore()
56     {
57         
return totalScore;
58     }
59     
public void settotalScore(int value)
60     {
61         totalScore =
value;
62     }
63
64
65     
public int getlevel1Score()
66     {
67         
return level1Score;
68     }
69     
public void setlevel1Score(int value)
70     {
71         level1Score =
value;
72     }
73
74     
public bool gethasShownInstructions()
75     {
76         
return hasShownInstructions;
77     }
78     
public void sethasShownInstructions(bool x)
79     {
80         hasShownInstructions = x;
81     }
82
83     
public int gettimeBonus()
84     {
85         
return timeBonus;
86     }
87     
public void settimeBonus(int value)
88     {
89         timeBonus =
value;
90     }
91
92     
public bool getisPlaying()
93     {
94         
return isPlaying;
95     }
96     
public void setisPlaying(bool value)
97     {
98         isPlaying =
value;
99     }
100
101     
public void addhitList(string value)
102     {
103         hitList.Add(
value);
104     }
105     
public void clearhitList()
106     {
107         hitList.Clear();
108     }
109     
public bool hitListContains(string value)
110     {
111         
bool ret = hitList.Contains(value);
112         
return ret;
113     }
114 }
// ends DataDictionary class


Gõ tìm kiếm nhanh...